home *** CD-ROM | disk | FTP | other *** search
/ Die Speccy' 97 / Die Speccy' 97.iso / amiga_system / the_aminet / comm / bbs / maxsutils.lha / MaxUtils / Doorpack101.lha / DoorPack.h < prev    next >
C/C++ Source or Header  |  1993-03-27  |  15KB  |  598 lines

  1. #define CAR if(doormsg->carrier==1) return;
  2. #define DROP if(doormsg->carrier==1) end();
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #include <exec/types.h>
  7. #include <exec/ports.h>
  8.  
  9. extern void end( void );
  10. extern void getsvar( int typ, char *mstring );
  11. extern void sendmessage( char mstring[], int nl );
  12. extern void hotkey( char mstring[], char *ostring );
  13. extern void prompt( char mstring[], char *ostring, int len );
  14. extern void sprompt( char mstring[], char *ostring, int len );
  15. extern void showfile( char mstring[] );
  16. extern void twituser( void );
  17. extern void addtime( int howmuch );
  18. extern void newaccess( int now );
  19. extern void MenuFunction( int function, int extra, char *string );
  20. extern void localmessage( char mstring[], int nl );
  21. extern void putmodemchar( char outd );
  22. extern void putscreenchar( char outd );
  23. extern void putdoorchar( char outd );
  24. extern void editfile( char mstring[], int maxlines );
  25. extern int chkfile( char *filename );
  26. extern int getsnum( int typ );
  27. extern int ReadStructure( FILE *fp, char *structure, int length );
  28. extern int WriteStructure( FILE *fp, char *structure, int length );
  29.  
  30. extern struct Task *mytask; /* Pointer to this task so we can name it */
  31.  
  32. void dmain( void );
  33.  
  34.  
  35. /*
  36.  
  37. The following code was kindly supplied by Robert Masters.  It deals with
  38. the MAX's configuration files, as outlined in the #?.text ascii files
  39. included in this archive.
  40.  
  41. */
  42.  
  43. #define MAXS_BBS        1.52
  44.  
  45. #define HEADER_STRING   "M A X's BBS Version 1.52  Copyright . 1992 by Anthony Barrett"
  46. #define HEADER_LENGTH   62
  47.  
  48. struct Section {
  49.    
  50.    char     name[42];
  51.    
  52.    LONG     low_access,
  53.             high_access,
  54.             reply_access,
  55.             max_count;
  56.             
  57.    ULONG    not_used          :23,
  58.             flag_echo         :1,
  59.             flag_files        :1,
  60.             flag_alias        :1,
  61.             flag_lk3          :1,
  62.             flag_lk2          :1,
  63.             flag_lk1          :1,
  64.             flag_del          :1,
  65.             flag_to           :1,
  66.             flag_frm          :1;
  67. };
  68.    
  69.  
  70. struct Fido  
  71.     {
  72.     UBYTE    section_number;
  73.     
  74.     UBYTE    flag_LZH          :1,
  75.             flag_old_filename :1;
  76.             
  77.     char    area_name[40];
  78.     
  79.     USHORT    dest_zone,
  80.             dest_net,
  81.             dest_node,
  82.             dest_point;
  83.             
  84.     char    password[8];
  85.             
  86.     USHORT    opt_bbs_zone,
  87.             opt_bbs_net,
  88.             opt_bbs_node,
  89.             opt_bbs_point;
  90.             
  91.     char    origin_line[58];
  92.     };
  93.  
  94.  
  95. struct Menu 
  96.     {
  97.     UBYTE    key;
  98.  
  99.     ULONG    function,
  100.             extra,
  101.             low_access,
  102.             high_access;
  103.    
  104.     char    string[41];
  105.     };
  106.  
  107.  
  108. struct Config 
  109.     {
  110.     char     header[HEADER_LENGTH-1];             /*don't ask me why it's short one*/
  111.    
  112.     UBYTE    new_files_public  :1,
  113.             esc_control_chars :1,
  114.             flashing_text     :1,
  115.             interlace         :1,
  116.             zmodem_XON_XOFF   :1,
  117.             iconify_on_start  :1,
  118.             zmodem_resume     :1,
  119.             show_connect_info :1;
  120.             
  121.     char    text_files_path[41],
  122.             user_files_path[41],
  123.             message_files_path[41],
  124.             files_files_path[42],
  125.             log_files_path[41],
  126.             bell_sample_filename[41],
  127.             chat_sample_filename[41];
  128.    
  129.     ULONG    bell_sample_play_rate,
  130.             chat_sample_play_rate,
  131.             max_users,
  132.             max_file_size,
  133.             logsize,
  134.             upload_reward,
  135.             sleep_time,
  136.             countdown_time,
  137.             chat_on_time,
  138.             chat_off_time,
  139.             max_chat_pages,
  140.             ud_on_time,
  141.             ud_off_time,
  142.             dimmer_time,
  143.             max_time,
  144.             min_upload_space,
  145.             add_sub_value,
  146.             optimize_messages_time,
  147.             login_time_limit,
  148.             answer_delay,
  149.             iconify_position,
  150.             inactive_days;
  151.    
  152.    char     door_files_path[41];
  153.    
  154.    char     opt_files_paths[30][41];
  155.             
  156.    UBYTE    modem_blank       :3,
  157.             add_ul_reward     :1,
  158.             freeze_ul_clock   :1,
  159.             monochrome_display:1,
  160.             update_dl_log     :1,
  161.             update_cli_log    :1;
  162.                                                                                                  
  163.    USHORT   clock_window_position_x;
  164.    USHORT   clock_window_position_y;
  165.    
  166.    char     attached_files_path[41],
  167.             bbs_font_filename[41],
  168.             window_font_filename[41],
  169.             execute_logoff_filename[41];
  170.    
  171.    ULONG    attached_files_old_days,
  172.             max_bps,
  173.             min_bps;
  174.                        
  175.    char     modem_setup[41],
  176.             _300_connect[41],
  177.             _600_connect[41],
  178.             _1200_connect[41],
  179.             _2400_connect[41],
  180.             _4800_connect[41],
  181.             _9600_connect[41],
  182.             _19200_connect[41],
  183.             _38400_connect[41],
  184.             busy[41],
  185.             no_dial_tone[41],
  186.             device_name[27];
  187.               
  188.    ULONG    serial_blank      :27,
  189.             auto_connect      :1,
  190.             slow_command      :1,
  191.             send_setup_twice  :1,
  192.             locked_bps_rate   :1,
  193.             _7_wire_handshake :1;
  194.  
  195.    ULONG    serial_dev_unit;
  196.          
  197.    char     _12000_connect[41],
  198.             _14400_connect[41];
  199.                  
  200.    ULONG    guest_blank       :27,
  201.             guest_afa         :1,
  202.             guest_dn          :1,
  203.             guest_up          :1,
  204.             guest_wr          :1,
  205.             guest_rd          :1;
  206.               
  207.    ULONG    member_blank      :27,
  208.             member_afa        :1,
  209.             member_dn         :1,
  210.             member_up         :1,
  211.             member_wr         :1,
  212.             member_rd         :1;
  213.             
  214.    ULONG    guest_access_level,
  215.             guest_time_limit,
  216.             guest_ratio,
  217.             guest_max_time_bank,
  218.             
  219.             member_access_level,
  220.             member_time_limit,
  221.             member_ratio,
  222.             member_max_time_bank;
  223.             
  224.    struct   Section  section[100];
  225.    
  226.    char     text_strings[350][100],
  227.             macro_strings[20][100],
  228.             
  229.             fido_inbound_path[42],
  230.             fido_outbound_path[42],
  231.             fido_origin_line[58],
  232.             fido_bbs_name[60];
  233.             
  234.    USHORT   bbs_address_zone,
  235.             bbs_address_net,
  236.             bbs_address_node,
  237.             bbs_address_point;
  238.             
  239.    char     sysop_name[20],
  240.             
  241.             make_LZH_string[41],
  242.             unLZH_string[41],
  243.             
  244.             phone_number_dial[21][41],
  245.             
  246.             execute_program_string[21][41];
  247.             
  248.    ULONG    phone_number_dial_time[21],
  249.             execute_program_time[21];
  250.             
  251.    char     phone_number_day_count[21],
  252.             execute_program_day_count[21];
  253.             
  254.    ULONG    dial_blank           :11,
  255.             dial_flags_phone_21  :1,
  256.             dial_flags_phone_20  :1,
  257.             dial_flags_phone_19  :1,
  258.             dial_flags_phone_18  :1,
  259.             dial_flags_phone_17  :1,
  260.             dial_flags_phone_16  :1,
  261.             dial_flags_phone_15  :1,
  262.             dial_flags_phone_14  :1,
  263.             dial_flags_phone_13  :1,
  264.             dial_flags_phone_12  :1,
  265.             dial_flags_phone_11  :1,
  266.             dial_flags_phone_10  :1,
  267.             dial_flags_phone_9   :1,
  268.             dial_flags_phone_8   :1,
  269.             dial_flags_phone_7   :1,
  270.             dial_flags_phone_6   :1,
  271.             dial_flags_phone_5   :1,
  272.             dial_flags_phone_4   :1,
  273.             dial_flags_phone_3   :1,
  274.             dial_flags_phone_2   :1,
  275.             dial_flags_phone_1   :1;
  276.             
  277.    ULONG    execute_blank        :11,
  278.             execute_flags_21     :1,
  279.             execute_flags_20     :1,
  280.             execute_flags_19     :1,
  281.             execute_flags_18     :1,
  282.             execute_flags_17     :1,
  283.             execute_flags_16     :1,
  284.             execute_flags_15     :1,
  285.             execute_flags_14     :1,
  286.             execute_flags_13     :1,
  287.             execute_flags_12     :1,
  288.             execute_flags_11     :1,
  289.             execute_flags_10     :1,
  290.             execute_flags_9      :1,
  291.             execute_flags_8      :1,
  292.             execute_flags_7      :1,
  293.             execute_flags_6      :1,
  294.             execute_flags_5      :1,
  295.             execute_flags_4      :1,
  296.             execute_flags_3      :1,
  297.             execute_flags_2      :1,
  298.             execute_flags_1      :1;
  299.         
  300.    ULONG    max_retries,
  301.             time_out,
  302.             redial_delay,
  303.             fido_on_time,
  304.             fido_off_time,
  305.             message_import_time;
  306.             
  307.    ULONG    fido_blank        :22,
  308.             no_care_import    :1,
  309.             update_log        :1,
  310.             show_cntrl_info   :1,
  311.             fidonet_only      :1,
  312.             allow_waZOO       :1,
  313.             allow_telink      :1,
  314.             allow_send        :1,
  315.             allow_pickup      :1,
  316.             auto_execute      :1,
  317.             auto_fidonet      :1;
  318.                         
  319.    struct   Fido  fido[200];
  320.    };
  321.  
  322.  
  323. struct Config_Menus  
  324.    {
  325.    ULONG    menu_number;
  326.    
  327.    char     text_filename[41];
  328.    
  329.    struct   Menu  menu[10];
  330.    };
  331.  
  332. /* After reading the Config, keep reading Config_Menus until the end of 
  333. the file. There may be more than 1 * 10 Menu structs per menu_number..*/
  334.  
  335. struct File_Data_Header 
  336.    {
  337.    UBYTE    header[HEADER_LENGTH];
  338.    
  339.    ULONG    total_active,
  340.             section_count[100];
  341.    };
  342.  
  343.  
  344. struct File_Data 
  345.    {
  346.    ULONG    date,
  347.             time,
  348.             length,
  349.             downloads;
  350.    
  351.    UBYTE    not_used_A        :4,            
  352.             flag_gone         :1,
  353.             flag_new          :1,
  354.             flag_lock         :1,
  355.             flag_del          :1;
  356.             
  357.    UBYTE    section_number,
  358.             filename[41],
  359.             description[60],
  360.             from[41],
  361.             from_alias[41],
  362.             from_node;
  363.    };
  364.  
  365.  
  366. struct File_Index_Header 
  367.    {
  368.    UBYTE    header[HEADER_LENGTH];
  369.    };
  370.  
  371. struct File_Index 
  372.    {
  373.    UBYTE    filename[41],
  374.             section_number,
  375.                     
  376.             not_used_A        :5,            
  377.             flag_new          :1,
  378.             flag_lock         :1,
  379.             flag_del          :1,
  380.             
  381.             reserved;     
  382.    };
  383.  
  384. struct Log_Data_Header 
  385.    {
  386.    UBYTE    header[HEADER_LENGTH];
  387.    
  388.    ULONG    total_active,
  389.             start;
  390.    };
  391.  
  392.  
  393. struct Log_Data 
  394.    {
  395.    UBYTE    name[41],
  396.             exit_code;     /* use enum Exit_Code */
  397.             
  398.    ULONG    logged_on_days,
  399.             logged_on_mins,
  400.             logged_off_days,
  401.             logged_off_mins;
  402.    
  403.    USHORT   messages_read,
  404.             messages_left,
  405.             uploads,
  406.             downloads,
  407.             baud_rate,
  408.             
  409.             not_used_A        :14,
  410.             flag_cli          :1,
  411.             flag_paged        :1; 
  412.    };           
  413.  
  414. enum Exit_Code 
  415.    {
  416.    Normal, Slow_baud_rate, Userfile_full, Lost_carrier,
  417.    Security_violation, Locked_out, Out_of_time, Sleep_disconnect,
  418.    Twited, DOS_read_error, DOS_write_error, Low_mem_error,
  419.    System_event, Forced_hangup, Slow_login, Reserved_BBS
  420.    };
  421.  
  422.  
  423. struct Message_Data_Header 
  424.    {
  425.    UBYTE    header[HEADER_LENGTH];
  426.    
  427.    ULONG    total_active,
  428.             highest,
  429.             section_count[100];
  430.    };
  431.  
  432. struct Message_Data 
  433.    {
  434.    ULONG    message_number,
  435.             date,
  436.             time,
  437.             previous;
  438.             
  439.    USHORT   replies;
  440.    
  441.    ULONG    position;
  442.    
  443.    USHORT   length,
  444.             
  445.             length_space,
  446.             
  447.             not_used_A        :9,
  448.             flag_netmail      :1,
  449.             flag_file_attach  :1,
  450.             flag_import       :1,
  451.             flag_forward      :1,
  452.             flag_locked       :1,
  453.             flag_received     :1,            
  454.             flag_del          :1;
  455.             
  456.             
  457.    UBYTE    section_number,
  458.             from[41],
  459.             to[41],
  460.             subject[72],
  461.             from_alias[41],
  462.             to_alias[41],
  463.             pad;
  464.             
  465.   USHORT    orig_node,
  466.             dest_node,
  467.             orig_net,
  468.             dest_net;
  469.    };
  470.  
  471. struct Message_Index_Header 
  472.    {
  473.    UBYTE    header[HEADER_LENGTH];
  474.    };
  475.  
  476. struct Message_Index 
  477.    {
  478.    ULONG    message_number;
  479.    
  480.    UBYTE    section_number,
  481.    
  482.             not_used_A        :7,
  483.             flag_del          :1;
  484.    };
  485.  
  486. struct User_Data_Header 
  487.    {
  488.    UBYTE    header[HEADER_LENGTH];
  489.    
  490.    ULONG    total_calls;
  491.    };
  492.  
  493.  
  494. struct User_Data 
  495.    {
  496.    UBYTE    name[41],
  497.             suburb[40],
  498.             password[21],
  499.             phone[21],
  500.             computer[21],
  501.             comment[100];
  502.    
  503.    ULONG    time_remain,
  504.             access_level,
  505.             time_limit,
  506.             du_ratio,
  507.             last_message_read,
  508.             page_length,
  509.             calls,
  510.             messages,
  511.             uploads,
  512.             downloads,
  513.             last_date_on,
  514.             last_time_on,
  515.             
  516.             not_used_A        :19,
  517.             flag_file_attach  :1,
  518.             flag_junk_mail    :1,
  519.             flag_file_desc    :1,
  520.             flag_lck          :1,
  521.             flag_cls          :1,
  522.             flag_pause        :1,
  523.             flag_fse          :1,
  524.             flag_ansi         :1,
  525.             flag_bltn         :1,
  526.             flag_dn           :1,
  527.             flag_up           :1,
  528.             flag_wr           :1,
  529.             flag_rd           :1,           
  530.             
  531.             time_bank,
  532.             transfer_protocol,
  533.             max_time_bank;
  534.    };         
  535.  
  536.    
  537. struct User_Index_Header 
  538.    {
  539.    UBYTE    header[HEADER_LENGTH];
  540.    };
  541.  
  542. struct User_Index 
  543.    {
  544.    UBYTE    name[41];
  545.    };
  546.  
  547. /* This is included here just as a place for putting it, but this is the
  548. structure for the data file in my program 'Section_Path'. As several of my 
  549. programs use this data file, I have put the structure here should anyone 
  550. else wish to use it as a quick way of cross refrencing sections to paths.
  551.  
  552. There are some blanks in the struct that will not be used, they were only
  553. there for some future expansion. */
  554.  
  555. struct Section_Path_Data 
  556.    {
  557.    char     section[101],     /* the path no. that each section uses. 127 if not used */
  558.             path[101][81],    /* path names as from FilePaths.text */
  559.             files[80];        /* path to the File.data ect. */
  560.    };
  561.  
  562.  
  563. /* These are for use with the MasterPort functions of MAXs */
  564.  
  565. struct MultiStruct   
  566.     {
  567.     LONG    totalcalls;
  568.     LONG    totalusers;
  569.     LONG    activemessages;
  570.     LONG    highestmessage;
  571.     LONG    lowestmessage;
  572.     LONG    activefiles;
  573.     LONG    msgindexpointer;
  574.     LONG    msgindexsize;
  575.     LONG    fileindexpointer;
  576.     LONG    fileindexsize;
  577.     LONG    numbernodes;
  578.     LONG    onlineusers;
  579.     };
  580.  
  581. struct _DoorMsg 
  582.     {
  583.        struct   Message Door_Msg;
  584.     short    command;
  585.     short    data;
  586.     char     string[80];
  587.     short    carrier;
  588.     };
  589.  
  590. struct MasterPort 
  591.     {
  592.     struct   Message _Door_Msg;
  593.     WORD     command;
  594.     LONG     data;
  595.     char     string[80];
  596.     short    carrier;
  597.     };
  598.